package com.wl.springsecuritystudy.config;


import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.web.authentication.preauth.PreAuthenticatedAuthenticationToken;

import java.io.Serializable;
import java.util.Collection;

/**
 * 自定义token的身份认证信息
 * <p>
 * Principal : 用户ID
 * Credentials : jwt
 * Details : SessionInfo
 *
 */
public class JwtAuthenticationToken extends PreAuthenticatedAuthenticationToken implements Serializable {

    private static final long serialVersionUID = -2333619000404580551L;

    public JwtAuthenticationToken(Object aPrincipal, Object aCredentials) {
        super(aPrincipal, aCredentials);
    }

    public JwtAuthenticationToken(Object aPrincipal, Object aCredentials, Collection<? extends GrantedAuthority> anAuthorities) {
        super(aPrincipal, aCredentials, anAuthorities);
    }

    public void setSession(SessionInfo sessionInfo) {
        setDetails(sessionInfo);
    }

    public SessionInfo getSession() {
        return (SessionInfo) getDetails();
    }
}
